package com.batchbrake.buttons;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.Action;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.SwingConstants;
import javax.swing.border.Border;

public class ActionButton extends JButton implements MouseListener {
	private static final Border MOUSE_OVER_BORDER = BorderFactory.createCompoundBorder(	BorderFactory.createEmptyBorder(2, 0, 2, 0), 
																						BorderFactory.createMatteBorder(0, 0, 1, 0, Color.red));
//	private static final Border MOUSE_OUT_BORDER = BorderFactory.createCompoundBorder(	BorderFactory.createEmptyBorder(2, 0, 2, 0), 
//																						BorderFactory.createEmptyBorder(0, 0, 1, 0));
	
	private static final Border MOUSE_OUT_BORDER = BorderFactory.createEmptyBorder(2, 5, 2, 5);
	
	public ActionButton(Action action) {
		super(action);
		System.out.println(action.getValue(Action.NAME));
		this.initButton();
	}
	
	private void initButton() {
		this.setBorder(MOUSE_OUT_BORDER);
		this.setHorizontalAlignment(SwingConstants.LEFT);
		this.setContentAreaFilled(false);
		this.addMouseListener(this);
		this.setFont(this.getFont().deriveFont(Font.BOLD));
	}

	@Override
	public void mouseEntered(MouseEvent arg0) {
		this.setText("<html><u>" + getAction().getValue(Action.NAME) + "</u></div></html>");
	}

	@Override
	public void mouseExited(MouseEvent arg0) {
		this.setText("<html>" + getAction().getValue(Action.NAME) + "</html>");
	}

	@Override
	public void mouseClicked(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mousePressed(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseReleased(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}
}
